package com.lysj.merchant.desk.controller;

import com.lysj.admin.utils.spring.foundation.base.BaseController;
import com.lysj.admin.utils.web.ParamUtil;
import com.lysj.admin.utils.web.Resp;
import com.lysj.merchant.desk.domain.TeaCharge;
import com.lysj.merchant.desk.service.TeaChargeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author Created by drj on 2019-03-07 15:19:27
 * @description 茶位费控制层
 */
@Slf4j
@RestController
@RequestMapping("/merchant/tea_charge")
public class TeaChargeController extends BaseController<TeaCharge> {

    @Resource
    private TeaChargeService teaChargeService;

    @Override
    public TeaChargeService getService() {
        return teaChargeService;
    }

    @GetMapping("/find_by_store_id")
    public Resp findOne() {
        String storeId = "123";
        TeaCharge teaChargeQuery = teaChargeService.getRepository().findByStoreId(storeId);
        if (ParamUtil.isBlank(teaChargeQuery)) {
            TeaCharge teaCharge = new TeaCharge();
            teaCharge.setStoreId(storeId);
            teaCharge.setMoney(BigDecimal.ZERO);
            teaChargeService.save(teaCharge);
        }
        return new Resp().success(teaChargeQuery);
    }

}
